From 327777a291a736ed3e0ebb14b2be6cdbb664c907 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timm=20B=C3=A4der?= Date: Tue, 10 May 2016 18:33:37 +0200 Subject: [PATCH] Scale: Set the correct value alignment We're measuring both the width of the minimal and the maximal value for the value gadget, but only give the value the minimal width for its current value, resultnig in an always left-aligned value. Fix this by assigning the width of the value gadget to the value layout and letting pango align the text inside the layout. https://bugzilla.gnome.org/show_bug.cgi?id=766120 --- gtk/gtkscale.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c index 2223d37f28..fc0121de97 100644 --- a/gtk/gtkscale.c +++ b/gtk/gtkscale.c @@ -1903,8 +1903,23 @@ gtk_scale_get_layout (GtkScale *scale) if (!priv->layout) { + int min_layout_width; + if (priv->draw_value) - priv->layout = gtk_widget_create_pango_layout (GTK_WIDGET (scale), NULL); + priv->layout = gtk_widget_create_pango_layout (GTK_WIDGET (scale), NULL); + + gtk_css_gadget_get_preferred_size (priv->value_gadget, + GTK_ORIENTATION_HORIZONTAL, -1, + &min_layout_width, NULL, + NULL, NULL); + pango_layout_set_width (priv->layout, min_layout_width * PANGO_SCALE); + + if (priv->value_pos == GTK_POS_LEFT) + pango_layout_set_alignment (priv->layout, PANGO_ALIGN_RIGHT); + else if (priv->value_pos == GTK_POS_RIGHT) + pango_layout_set_alignment (priv->layout, PANGO_ALIGN_LEFT); + else + pango_layout_set_alignment (priv->layout, PANGO_ALIGN_CENTER); } if (priv->draw_value) -- 2.30.2